package com.ym.pms.service.impl;

import com.ym.pms.dao.*;
import com.ym.pms.model.Suite;
import com.ym.pms.service.DisplayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DisplayServiceImpl implements DisplayService {

    @Autowired
    ItemMapper itemMapper;
    @Autowired
    BuildingMapper buildingMapper;
    @Autowired
    SuiteMapper suiteMapper;
    @Autowired
    RoomMapper roomMapper;
    @Autowired
    BunkMapper bunkMapper;

    @Override
    public List<Map<String, String>> dormitoryInformation(String gender) {
        List<Map<String, String>> list = new ArrayList();
        List<Suite> suites = suiteMapper.findAllUsing();
        int i = 0;
        for (Suite suite : suites) {
            int size = roomMapper.findByGenderAndSuCoding(gender, suite.getSuCoding()).size();
            if(size == 0){
                continue;
            }
            Map<String, String> map = new HashMap<>();

            map.put("key", String.valueOf(i));

            map.put("roomNum",String.valueOf(size));

            String itName = suite.getItName();
            map.put("itemName",itName);

            String buName = suite.getSuBuname();
            map.put("buildingName",buName);

            String suName = suite.getSuName();
            map.put("suiteName",suName);

            String itCName = suite.getItCName();
            map.put("CName",itCName);

            Integer suFloor = suite.getSuFloor();
            map.put("floor",String.valueOf(suFloor));

            Double minRent = bunkMapper.getMinVBkRentBySuCoding(suite.getSuCoding());
            map.put("MinMoney",String.valueOf(minRent));

            String suRemark = suite.getSuRemark();
            map.put("remark",suRemark);

            map.put("suCoding",suite.getSuCoding());
            map.put("buCoding",suite.getSuBucoding());
            map.put("itCoding",suite.getSuItid());

            map.put("itemStyle","itemStyle-two");

            list.add(map);

            i++;
        }
        return list;
    }
}
